﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ITProject.WebUI.Models.Project;
using System.ComponentModel.DataAnnotations;
using ITProject.Domain.Entities;

namespace ITProject.WebUI.Models.ProjectUser
{
    public class ProjectUserMyFeatureViewModel
    {
        [Display(Name="Nazwa")]
        public string Name { get; set; }
        [Display(Name="Status")]
        public string Status { get; set; }
        [Display(Name="Priorytet")]
        public string Priority { get; set; }
        [Display(Name = "Planowana data zakończenia")]
        public string PlannedEndDate { get; set; }

        // ukryte
        public int FeatureId { get; set; }

        public static ProjectUserMyFeatureViewModel[] Convert(Feature[] userFeatures)
        {
            ProjectUserMyFeatureViewModel[] vmTab = new ProjectUserMyFeatureViewModel[userFeatures.Length];
            for (int i = 0; i < vmTab.Length; i++)
            {
                vmTab[i] = new ProjectUserMyFeatureViewModel
                {
                    Name = userFeatures[i].Name,
                    Priority = PriorityViewModel.ConvertFromByte(userFeatures[i].Priority),
                    Status = StatusName.ConvertFromByte(userFeatures[i].Status),
                    PlannedEndDate=userFeatures[i].PlannedEndDate.ToLongDateString(),
                    FeatureId=userFeatures[i].Id
                };
            }
            return vmTab;
        }
    }
}